<?php

namespace app\company\model;

use app\common\model\BaseModel;
use think\model\relation\BelongsTo;
use think\model\relation\HasMany;

class CheckStock extends BaseModel
{
    const CHECK_STATUS_NO = 1; // 未盘点
    const CHECK_STATUS_YES = 2; // 已盘点

    public function detail():HasMany
    {
        return $this->hasMany(CheckStockDetail::class,'check_stock_id','id');
    }

    public function createUser():BelongsTo
    {
        return $this->belongsTo(CompanyUser::class ,'create_user_id','id');
    }

    public function checkUser():BelongsTo
    {
        return $this->belongsTo(CompanyUser::class ,'check_user_id','id');
    }

    public function getCheckTimeAttr($value): string
    {
        if(!$value) return '暂未盘点';
        return date('Y-m-d H:i:s',$value);
    }
}